package com.bigknow.appstore.web.util;

import net.sourceforge.pinyin4j.PinyinHelper;
import org.apache.commons.lang3.StringUtils;

/**
 * Created by zhangwei on 2016/10/13.
 */
public class PinyinUtils {
    // 获取中文的首字母大写
    public static String getFirstUpperCase(String str) {

        String convert = "";
        for (int j = 0; j < str.length(); j++) {
            char word = str.charAt(j);
            String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word);
            if (pinyinArray != null) {
                convert += pinyinArray[0].charAt(0);
            } else {
                convert += word;
            }
        }
        return StringUtils.upperCase(convert);
    }
}
